/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package ua.i.kotionokyurievna.jewelryweb.controllers;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author kotionokyurievna
 */
@ManagedBean
@RequestScoped
public class ChangePasswordController {
    private String oldPassword;
    private String newPassword;
    private String newPasswordConfirm;

    /**
     * Creates a new instance of ChangePasswordController
     */
    public ChangePasswordController() {
        oldPassword = "";
        newPassword = "";
        newPasswordConfirm = "";
    }

    public ChangePasswordController(String oldPassword, String newPassword, 
            String newPasswordConfirm) {
        this.oldPassword = oldPassword;
        this.newPassword = newPassword;
        this.newPasswordConfirm = newPasswordConfirm;
    }

    public String getOldPassword() {
        return oldPassword;
    }

    public void setOldPassword(String oldPassword) {
        this.oldPassword = oldPassword;
    }

    public String getNewPassword() {
        return newPassword;
    }

    public void setNewPassword(String newPassword) {
        this.newPassword = newPassword;
    }

    public String getNewPasswordConfirm() {
        return newPasswordConfirm;
    }

    public void setNewPasswordConfirm(String newPasswordConfirm) {
        this.newPasswordConfirm = newPasswordConfirm;
    }
    
    public String changePassword(){
        if(!newPassword.equals(newPasswordConfirm)) {
           
            FacesContext.getCurrentInstance().addMessage(
            null,
            new FacesMessage(FacesMessage.SEVERITY_WARN,
            "Passwords does not match", null));
        }
        return "changePasswordPage";
    }
    
}
